package com.kuang.config;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class LoginInterceptor implements HandlerInterceptor {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        if(request.getRequestURI().contains("Login") ||request.getRequestURI().contains("login")){
            return true;
        }
        HttpSession session = request.getSession();
        System.out.println(session.getAttribute("userLoginInfo"));
        if (session.getAttribute("userLoginInfo") != null) {
            return true;
        }
        return false;
    }
}
